package wangkautil

import (
	"io/ioutil"
	"regexp"
)

const (
	QQBrowserToeknPath = "/data/data/com.tencent.mtt/shared_prefs/public_settings.xml"
)

var (
	simTokenRE = regexp.MustCompile(`<string name="tencent_sim_token">(.*?)</string>`)
)

func ClearQQBrowserTokenCache() (err error) {
	contents, err := ioutil.ReadFile(QQBrowserToeknPath)
	if err != nil {
		return
	}

	contents = simTokenRE.ReplaceAll(contents, []byte(`<string name="tencent_sim_token"></string>`))
	err = ioutil.WriteFile(QQBrowserToeknPath, contents, 0644)
	return
}
